package com.ruoyi.web.controller.dispatch;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DispatchTableMonitor;
import com.ruoyi.system.service.IDispatchTableMonitorService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 格监控Controller
 * 
 * @author ruoyi
 * @date 2025-03-02
 */
@RestController
@RequestMapping("/system/dispatchTableMonitor")
public class DispatchTableMonitorController extends BaseController
{
    @Autowired
    private IDispatchTableMonitorService dispatchTableMonitorService;

    /**
     * 查询格监控列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchTableMonitor:list')")
    @GetMapping("/list")
    public TableDataInfo list(DispatchTableMonitor dispatchTableMonitor)
    {
        startPage();
        List<DispatchTableMonitor> list = dispatchTableMonitorService.selectDispatchTableMonitorList(dispatchTableMonitor);
        return getDataTable(list);
    }

    /**
     * 导出格监控列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchTableMonitor:export')")
    @Log(title = "格监控", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DispatchTableMonitor dispatchTableMonitor)
    {
        List<DispatchTableMonitor> list = dispatchTableMonitorService.selectDispatchTableMonitorList(dispatchTableMonitor);
        ExcelUtil<DispatchTableMonitor> util = new ExcelUtil<DispatchTableMonitor>(DispatchTableMonitor.class);
        util.exportExcel(response, list, "格监控数据");
    }

    /**
     * 获取格监控详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchTableMonitor:query')")
    @GetMapping(value = "/{monitoringTableId}")
    public AjaxResult getInfo(@PathVariable("monitoringTableId") Long monitoringTableId)
    {
        return success(dispatchTableMonitorService.selectDispatchTableMonitorByMonitoringTableId(monitoringTableId));
    }

    /**
     * 新增格监控
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchTableMonitor:add')")
    @Log(title = "格监控", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DispatchTableMonitor dispatchTableMonitor)
    {
        return toAjax(dispatchTableMonitorService.insertDispatchTableMonitor(dispatchTableMonitor));
    }

    /**
     * 修改格监控
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchTableMonitor:edit')")
    @Log(title = "格监控", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DispatchTableMonitor dispatchTableMonitor)
    {
        return toAjax(dispatchTableMonitorService.updateDispatchTableMonitor(dispatchTableMonitor));
    }

    /**
     * 删除格监控
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchTableMonitor:remove')")
    @Log(title = "格监控", businessType = BusinessType.DELETE)
	@DeleteMapping("/{monitoringTableIds}")
    public AjaxResult remove(@PathVariable Long[] monitoringTableIds)
    {
        return toAjax(dispatchTableMonitorService.deleteDispatchTableMonitorByMonitoringTableIds(monitoringTableIds));
    }
}
